package random.fox.p2p.common;

import de.greenrobot.daogenerator.*;

/**
 * Created by wq on 15/3/20.
 */
public class DaoHelper {
    public static void main(String[] args) throws Exception {
        Schema schema = new Schema(1,"random.fox.p2p.bean.greendao");

        addMessage(schema);

        addTag(schema);

        addUser(schema);

        new DaoGenerator().generateAll(schema,"app/src/main/java/");
    }

    /**
     * 创建用户表
     * @param schema
     */
    private static void addUser(Schema schema){
        Entity tag = schema.addEntity("Tag");
        Property tagid = tag.addIdProperty().autoincrement().getProperty();
        tag.addStringProperty("tag");
        tag.addIntProperty("count");

        Entity user = schema.addEntity("User");
        user.addIdProperty().autoincrement();
        user.addStringProperty("uid").notNull();
        user.addIntProperty("sex");
        user.addStringProperty("nickname");
        user.addStringProperty("birthday");
        user.addStringProperty("school");
        user.addStringProperty("city");
        user.addStringProperty("phoneNumber");
        user.addStringProperty("headimg");
        user.addToMany(tag,tagid);
    }

    /**
     * MESSAGE
     * @param schema
     */
    private static void addMessage(Schema schema){
        Entity message = schema.addEntity("Message");
        message.addIdProperty().autoincrement();
        message.addIntProperty("uid");
        message.addIntProperty("mid");
        message.addStringProperty("theme");
        message.addStringProperty("nickname");
        message.addStringProperty("head_url");
        message.addStringProperty("m_url");
        message.addStringProperty("content");
        message.addStringProperty("location");
        message.addDateProperty("time");
        message.addIntProperty("likeCount");
    }

    private static void addTag(Schema schema){

    }
}
